using System;
using System.Collections.Generic;
using UnityEngine;

namespace RGuang.PlathformCtrl.FSM
{
    public class StateMachine : MonoBehaviour
    {
        IState currentState;
        protected Dictionary<System.Type, IState> stateTabe;

        private void Update()
        {
            currentState.LogicUpdate();
        }

        private void FixedUpdate()
        {
            currentState.PhysicUpdate();
        }

        protected void SwitchOn(IState newState)
        {
            currentState = newState;
            currentState.Enter();
        }

        public void SwitchState(IState newState)
        {
            currentState.Exit();
            SwitchOn(newState);
        }
        public void SwitchState(System.Type newStateType)
        {
            SwitchState(stateTabe[newStateType]);
        }

    }

}
